<template>
  <div class="activity-detail-view">
    <div v-if="loading" class="loading-state">
      <div class="loading-spinner"></div>
      <p>正在加载活动详情...</p>
    </div>

    <div v-else-if="!activity" class="error-state glass-card">
      <svg fill="none" viewBox="0 0 24 24">
        <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
        <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="8" y2="12"/>
        <line stroke="currentColor" stroke-width="2" x1="12" x2="12.01" y1="16" y2="16"/>
      </svg>
      <h3>活动不存在</h3>
      <p>该活动可能已被删除或您没有查看权限</p>
      <router-link class="back-btn" to="/activity">
        <svg fill="none" viewBox="0 0 24 24">
          <path d="M19 12H5M12 19l-7-7 7-7" stroke="currentColor" stroke-width="2"/>
        </svg>
        返回活动列表
      </router-link>
    </div>

    <div v-else class="activity-content">
      <!-- 活动头部 -->
      <div class="activity-header">
        <div class="header-background">
          <img
            v-if="activity.coverImage"
            :alt="activity.title"
            :src="activity.coverImage"
          />
          <div v-else class="placeholder-background"></div>
          <div class="header-overlay"></div>
        </div>

        <div class="header-content">
          <div class="header-top">
            <button class="back-btn" @click="goBack">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M19 12H5M12 19l-7-7 7-7" stroke="currentColor" stroke-width="2"/>
              </svg>
              返回
            </button>

            <div class="header-actions">
              <button v-if="activity.canShare" class="action-btn share" @click="shareActivity">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8" stroke="currentColor" stroke-width="2"/>
                  <polyline points="16,6 12,2 8,6" stroke="currentColor" stroke-width="2"/>
                  <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="2" y2="15"/>
                </svg>
                分享
              </button>

              <button v-if="activity.canEdit" class="action-btn edit" @click="editActivity">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" stroke="currentColor" stroke-width="2"/>
                  <path d="M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" stroke="currentColor" stroke-width="2"/>
                </svg>
                编辑
              </button>

              <button class="action-btn more" @click="showMoreMenu = !showMoreMenu">
                <svg fill="none" viewBox="0 0 24 24">
                  <circle cx="12" cy="12" r="1" stroke="currentColor" stroke-width="2"/>
                  <circle cx="19" cy="12" r="1" stroke="currentColor" stroke-width="2"/>
                  <circle cx="5" cy="12" r="1" stroke="currentColor" stroke-width="2"/>
                </svg>
              </button>

              <div v-if="showMoreMenu" class="more-menu" @click.stop>
                <button class="menu-item" @click="copyLink">
                  <svg fill="none" viewBox="0 0 24 24">
                    <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" stroke="currentColor" stroke-width="2"/>
                    <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" stroke="currentColor" stroke-width="2"/>
                  </svg>
                  复制链接
                </button>
                <button class="menu-item" @click="reportActivity">
                  <svg fill="none" viewBox="0 0 24 24">
                    <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                    <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="8" y2="12"/>
                    <line stroke="currentColor" stroke-width="2" x1="12" x2="12.01" y1="16" y2="16"/>
                  </svg>
                  举报
                </button>
              </div>
            </div>
          </div>

          <div class="header-main">
            <div :class="activity.status" class="activity-status">
              {{ getStatusText(activity.status) }}
            </div>

            <h1 class="activity-title">{{ activity.title }}</h1>

            <div class="activity-meta">
              <div class="meta-item">
                <svg fill="none" viewBox="0 0 24 24">
                  <rect height="18" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="18" x="3" y="4"/>
                  <line stroke="currentColor" stroke-width="2" x1="16" x2="16" y1="2" y2="6"/>
                  <line stroke="currentColor" stroke-width="2" x1="8" x2="8" y1="2" y2="6"/>
                </svg>
                {{ getTypeText(activity.type) }}
              </div>

              <div class="meta-item">
                <svg fill="none" viewBox="0 0 24 24">
                  <path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" stroke="currentColor" stroke-width="2"/>
                  <circle cx="8.5" cy="7" r="4" stroke="currentColor" stroke-width="2"/>
                  <line stroke="currentColor" stroke-width="2" x1="20" x2="20" y1="8" y2="14"/>
                  <line stroke="currentColor" stroke-width="2" x1="23" x2="17" y1="11" y2="11"/>
                </svg>
                创建者：{{ activity.creator?.name }}
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 参与按钮区域 -->
      <div v-if="activity.canParticipate" class="participation-section glass-card">
        <div class="participation-content">
          <div class="participation-info">
            <div class="participation-count">
              <span class="count-number">{{ activity.participantCount }}</span>
              <span class="count-max">/{{ activity.maxParticipants || '∞' }}</span>
              <span class="count-text">人参与</span>
            </div>

            <div v-if="activity.registrationDeadline" class="registration-deadline">
              <svg fill="none" viewBox="0 0 24 24">
                <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                <polyline points="12,6 12,12 16,14" stroke="currentColor" stroke-width="2"/>
              </svg>
              报名截止：{{ formatDateTime(activity.registrationDeadline) }}
            </div>
          </div>

          <button
            :class="{ participating: activity.isParticipating, full: isActivityFull }"
            :disabled="isActivityFull && !activity.isParticipating"
            class="participate-btn"
            @click="toggleParticipation"
          >
            <svg v-if="participationLoading" class="loading-spinner" fill="none" viewBox="0 0 24 24">
              <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
              <path d="M12 6v6l4 2" stroke="currentColor" stroke-width="2"/>
            </svg>
            <svg v-else-if="activity.isParticipating" fill="none" viewBox="0 0 24 24">
              <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" stroke="currentColor" stroke-width="2"/>
              <polyline points="22,4 12,14.01 9,11.01" stroke="currentColor" stroke-width="2"/>
            </svg>
            <svg v-else fill="none" viewBox="0 0 24 24">
              <path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" stroke="currentColor" stroke-width="2"/>
              <circle cx="8.5" cy="7" r="4" stroke="currentColor" stroke-width="2"/>
              <line stroke="currentColor" stroke-width="2" x1="20" x2="20" y1="8" y2="14"/>
              <line stroke="currentColor" stroke-width="2" x1="23" x2="17" y1="11" y2="11"/>
            </svg>

            <span v-if="participationLoading">处理中...</span>
            <span v-else-if="activity.isParticipating">已参加</span>
            <span v-else-if="isActivityFull">人数已满</span>
            <span v-else>参加活动</span>
          </button>
        </div>
      </div>

      <!-- 活动详情内容 -->
      <div class="activity-details">
        <!-- 基本信息 -->
        <div class="detail-section glass-card">
          <div class="section-header">
            <h3 class="section-title">
              <svg fill="none" viewBox="0 0 24 24">
                <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="16" y2="12"/>
                <line stroke="currentColor" stroke-width="2" x1="12" x2="12.01" y1="8" y2="8"/>
              </svg>
              活动详情
            </h3>
          </div>

          <div class="section-content">
            <p v-if="activity.description" class="activity-description">{{ activity.description }}</p>
            <p v-else class="no-description">暂无活动描述</p>

            <div class="detail-grid">
              <div class="detail-item">
                <div class="detail-label">
                  <svg fill="none" viewBox="0 0 24 24">
                    <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                    <polyline points="12,6 12,12 16,14" stroke="currentColor" stroke-width="2"/>
                  </svg>
                  开始时间
                </div>
                <div class="detail-value">{{ formatDateTime(activity.startTime) }}</div>
              </div>

              <div v-if="activity.endTime" class="detail-item">
                <div class="detail-label">
                  <svg fill="none" viewBox="0 0 24 24">
                    <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                    <polyline points="12,6 12,12 16,14" stroke="currentColor" stroke-width="2"/>
                  </svg>
                  结束时间
                </div>
                <div class="detail-value">{{ formatDateTime(activity.endTime) }}</div>
              </div>

              <div class="detail-item">
                <div class="detail-label">
                  <svg fill="none" viewBox="0 0 24 24">
                    <circle cx="12" cy="10" r="3" stroke="currentColor" stroke-width="2"/>
                    <path d="m8.21 13.89 3.79 2.11 3.79-2.11" stroke="currentColor" stroke-width="2"/>
                  </svg>
                  活动地点
                </div>
                <div class="detail-value">
                  <div>{{ activity.locationName }}</div>
                  <div v-if="activity.locationAddress" class="detail-sub">{{ activity.locationAddress }}</div>
                </div>
              </div>

              <div v-if="activity.budgetPerPerson" class="detail-item">
                <div class="detail-label">
                  <svg fill="none" viewBox="0 0 24 24">
                    <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="1" y2="23"/>
                    <path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" stroke="currentColor" stroke-width="2"/>
                  </svg>
                  人均预算
                </div>
                <div class="detail-value">{{ formatCurrency(activity.budgetPerPerson, activity.currency) }}</div>
              </div>

              <div v-if="activity.requirements" class="detail-item full-width">
                <div class="detail-label">
                  <svg fill="none" viewBox="0 0 24 24">
                    <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2"/>
                    <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2"/>
                    <line stroke="currentColor" stroke-width="2" x1="16" x2="8" y1="13" y2="13"/>
                  </svg>
                  参与要求
                </div>
                <div class="detail-value">{{ activity.requirements }}</div>
              </div>

              <div v-if="activity.notes" class="detail-item full-width">
                <div class="detail-label">
                  <svg fill="none" viewBox="0 0 24 24">
                    <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2"/>
                    <polyline points="14,2 14,8 20,8" stroke="currentColor" stroke-width="2"/>
                    <line stroke="currentColor" stroke-width="2" x1="16" x2="8" y1="13" y2="13"/>
                    <line stroke="currentColor" stroke-width="2" x1="16" x2="8" y1="17" y2="17"/>
                  </svg>
                  活动备注
                </div>
                <div class="detail-value">{{ activity.notes }}</div>
              </div>
            </div>
          </div>
        </div>

        <!-- 参与者列表 -->
        <div class="detail-section glass-card">
          <div class="section-header">
            <h3 class="section-title">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" stroke="currentColor" stroke-width="2"/>
                <circle cx="9" cy="7" r="4" stroke="currentColor" stroke-width="2"/>
                <path d="M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" stroke="currentColor" stroke-width="2"/>
              </svg>
              参与者 ({{ participants.length }})
            </h3>
          </div>

          <div class="section-content">
            <div v-if="participants.length > 0" class="participants-list">
              <div
                v-for="participant in participants"
                :key="participant.id"
                class="participant-item"
              >
                <div class="participant-avatar">
                  <img
                    v-if="participant.avatar"
                    :alt="participant.name"
                    :src="participant.avatar"
                  />
                  <div v-else class="avatar-placeholder">
                    {{ participant.name.charAt(0) }}
                  </div>
                  <div v-if="participant.isCreator" class="creator-badge" title="创建者">
                    <svg fill="none" viewBox="0 0 24 24">
                      <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" fill="currentColor"/>
                    </svg>
                  </div>
                </div>

                <div class="participant-info">
                  <div class="participant-name">{{ participant.name }}</div>
                  <div class="participant-meta">
                    <span class="join-time">{{ formatRelativeTime(participant.joinTime) }}加入</span>
                    <span v-if="participant.relation" class="relation">{{ participant.relation }}</span>
                  </div>
                </div>

                <div v-if="participant.status" :class="participant.status" class="participant-status">
                  {{ getParticipantStatusText(participant.status) }}
                </div>
              </div>
            </div>

            <div v-else class="empty-participants">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" stroke="currentColor" stroke-width="2"/>
                <circle cx="8.5" cy="7" r="4" stroke="currentColor" stroke-width="2"/>
                <line stroke="currentColor" stroke-width="2" x1="20" x2="20" y1="8" y2="14"/>
                <line stroke="currentColor" stroke-width="2" x1="23" x2="17" y1="11" y2="11"/>
              </svg>
              <p>暂无参与者</p>
            </div>
          </div>
        </div>

        <!-- 活动相册 -->
        <div v-if="activityPhotos.length > 0" class="detail-section glass-card">
          <div class="section-header">
            <h3 class="section-title">
              <svg fill="none" viewBox="0 0 24 24">
                <rect height="18" rx="2" ry="2" stroke="currentColor" stroke-width="2" width="18" x="3" y="3"/>
                <circle cx="8.5" cy="8.5" r="1.5" stroke="currentColor" stroke-width="2"/>
                <polyline points="21,15 16,10 5,21" stroke="currentColor" stroke-width="2"/>
              </svg>
              活动相册 ({{ activityPhotos.length }})
            </h3>

            <button v-if="activity.canUpload" class="upload-btn" @click="showUploadModal = true">
              <svg fill="none" viewBox="0 0 24 24">
                <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                <line stroke="currentColor" stroke-width="2" x1="12" x2="12" y1="8" y2="16"/>
                <line stroke="currentColor" stroke-width="2" x1="8" x2="16" y1="12" y2="12"/>
              </svg>
              上传照片
            </button>
          </div>

          <div class="section-content">
            <div class="photos-grid">
              <div
                v-for="photo in activityPhotos"
                :key="photo.id"
                class="photo-item"
                @click="viewPhoto(photo)"
              >
                <img :alt="photo.description" :src="photo.thumbnailUrl" />
                <div class="photo-overlay">
                  <div class="photo-info">
                    <div class="photo-uploader">{{ photo.uploaderName }}</div>
                    <div class="photo-time">{{ formatRelativeTime(photo.uploadTime) }}</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 评论区域 -->
        <div v-if="activity.allowComments" class="detail-section glass-card">
          <div class="section-header">
            <h3 class="section-title">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" stroke="currentColor" stroke-width="2"/>
              </svg>
              评论 ({{ comments.length }})
            </h3>
          </div>

          <div class="section-content">
            <!-- 评论输入框 -->
            <div class="comment-input">
              <div class="user-avatar">
                <img
                  v-if="currentUser?.avatar"
                  :alt="currentUser.name"
                  :src="currentUser.avatar"
                />
                <div v-else class="avatar-placeholder">
                  {{ currentUser?.name?.charAt(0) || '我' }}
                </div>
              </div>

              <div class="input-container">
                <textarea
                  v-model="newComment"
                  class="comment-textarea"
                  maxlength="500"
                  placeholder="写下您的想法..."
                  rows="3"
                  @keydown.ctrl.enter="submitComment"
                ></textarea>

                <div class="input-actions">
                  <div class="input-counter">{{ newComment.length }}/500</div>
                  <button
                    :disabled="!newComment.trim() || commentSubmitting"
                    class="submit-btn"
                    @click="submitComment"
                  >
                    <svg v-if="commentSubmitting" class="loading-spinner" fill="none" viewBox="0 0 24 24">
                      <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
                    </svg>
                    <svg v-else fill="none" viewBox="0 0 24 24">
                      <line stroke="currentColor" stroke-width="2" x1="22" x2="11" y1="2" y2="13"/>
                      <polygon fill="currentColor" points="22,2 15,22 11,13 2,9 22,2"/>
                    </svg>
                    {{ commentSubmitting ? '发送中...' : '发送' }}
                  </button>
                </div>
              </div>
            </div>

            <!-- 评论列表 -->
            <div v-if="comments.length > 0" class="comments-list">
              <div
                v-for="comment in comments"
                :key="comment.id"
                class="comment-item"
              >
                <div class="comment-avatar">
                  <img
                    v-if="comment.user.avatar"
                    :alt="comment.user.name"
                    :src="comment.user.avatar"
                  />
                  <div v-else class="avatar-placeholder">
                    {{ comment.user.name.charAt(0) }}
                  </div>
                </div>

                <div class="comment-content">
                  <div class="comment-header">
                    <div class="comment-author">{{ comment.user.name }}</div>
                    <div class="comment-time">{{ formatRelativeTime(comment.createTime) }}</div>
                  </div>

                  <div class="comment-text">{{ comment.content }}</div>

                  <div class="comment-actions">
                    <button
                      :class="{ active: comment.isLiked }"
                      class="comment-action"
                      @click="toggleCommentLike(comment)"
                    >
                      <svg fill="none" viewBox="0 0 24 24">
                        <path :fill="comment.isLiked ? 'currentColor' : 'none'" d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" stroke="currentColor" stroke-width="2"/>
                      </svg>
                      {{ comment.likeCount || 0 }}
                    </button>

                    <button class="comment-action" @click="replyToComment(comment)">
                      <svg fill="none" viewBox="0 0 24 24">
                        <polyline points="9,17 4,12 9,7" stroke="currentColor" stroke-width="2"/>
                        <path d="M20 18v-2a4 4 0 0 0-4-4H4" stroke="currentColor" stroke-width="2"/>
                      </svg>
                      回复
                    </button>
                  </div>
                </div>
              </div>
            </div>

            <div v-else class="empty-comments">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" stroke="currentColor" stroke-width="2"/>
              </svg>
              <p>还没有评论，快来说两句吧！</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 照片查看器 -->
    <div v-if="showPhotoViewer" class="photo-viewer" @click.self="closePhotoViewer">
      <div class="photo-viewer-content">
        <button class="viewer-close" @click="closePhotoViewer">
          <svg fill="none" viewBox="0 0 24 24">
            <line stroke="currentColor" stroke-width="2" x1="18" x2="6" y1="6" y2="18"/>
            <line stroke="currentColor" stroke-width="2" x1="6" x2="18" y1="6" y2="18"/>
          </svg>
        </button>

        <img v-if="currentPhoto" :alt="currentPhoto.description" :src="currentPhoto.originalUrl" />

        <div class="photo-info-panel">
          <div class="info-header">
            <div class="uploader-info">
              <div class="uploader-avatar">
                <img
                  v-if="currentPhoto?.uploaderAvatar"
                  :alt="currentPhoto.uploaderName"
                  :src="currentPhoto.uploaderAvatar"
                />
                <div v-else class="avatar-placeholder">
                  {{ currentPhoto?.uploaderName?.charAt(0) }}
                </div>
              </div>
              <div>
                <div class="uploader-name">{{ currentPhoto?.uploaderName }}</div>
                <div class="upload-time">{{ formatDateTime(currentPhoto?.uploadTime) }}</div>
              </div>
            </div>
          </div>

          <div v-if="currentPhoto?.description" class="photo-description">
            {{ currentPhoto.description }}
          </div>
        </div>
      </div>
    </div>

    <!-- 上传照片模态框 -->
    <div v-if="showUploadModal" class="modal-overlay" @click.self="showUploadModal = false">
      <div class="modal-dialog">
        <div class="modal-header">
          <h3>上传活动照片</h3>
          <button class="modal-close" @click="showUploadModal = false">
            <svg fill="none" viewBox="0 0 24 24">
              <line stroke="currentColor" stroke-width="2" x1="18" x2="6" y1="6" y2="18"/>
              <line stroke="currentColor" stroke-width="2" x1="6" x2="18" y1="6" y2="18"/>
            </svg>
          </button>
        </div>

        <div class="modal-body">
          <div class="upload-area" @click="selectFiles" @dragover.prevent @drop.prevent="handleDrop">
            <div class="upload-content">
              <svg fill="none" viewBox="0 0 24 24">
                <path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z" stroke="currentColor" stroke-width="2"/>
                <circle cx="12" cy="13" r="3" stroke="currentColor" stroke-width="2"/>
              </svg>
              <h4>选择或拖拽照片到此处</h4>
              <p>支持 JPG、PNG 格式，单张最大 10MB</p>
            </div>
          </div>

          <input
            ref="uploadInputRef"
            accept="image/*"
            class="file-input"
            multiple
            type="file"
            @change="handleFileSelect"
          />

          <div v-if="uploadFiles.length > 0" class="upload-preview">
            <h4>待上传照片 ({{ uploadFiles.length }})</h4>
            <div class="preview-grid">
              <div
                v-for="(file, index) in uploadFiles"
                :key="index"
                class="preview-item"
              >
                <img :alt="file.name" :src="file.preview" />
                <button class="remove-file" @click="removeUploadFile(index)">
                  <svg fill="none" viewBox="0 0 24 24">
                    <line stroke="currentColor" stroke-width="2" x1="18" x2="6" y1="6" y2="18"/>
                    <line stroke="currentColor" stroke-width="2" x1="6" x2="18" y1="6" y2="18"/>
                  </svg>
                </button>
              </div>
            </div>
          </div>
        </div>

        <div class="modal-footer">
          <button class="modal-btn secondary" @click="showUploadModal = false">取消</button>
          <button
            :disabled="uploadFiles.length === 0 || uploading"
            class="modal-btn primary"
            @click="uploadPhotos"
          >
            <svg v-if="uploading" class="loading-spinner" fill="none" viewBox="0 0 24 24">
              <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/>
            </svg>
            {{ uploading ? `上传中... (${uploadProgress}%)` : `上传 ${uploadFiles.length} 张照片` }}
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, computed, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { Notify } from '@opentiny/vue'

const router = useRouter()
const route = useRoute()

interface Activity {
  id: number
  title: string
  description: string
  type: string
  status: string
  startTime: string
  endTime?: string
  locationName: string
  locationAddress?: string
  coverImage?: string
  participantCount: number
  maxParticipants?: number
  budgetPerPerson?: number
  currency?: string
  registrationDeadline?: string
  requirements?: string
  notes?: string
  isParticipating: boolean
  canParticipate: boolean
  canEdit: boolean
  canDelete: boolean
  canShare: boolean
  canUpload: boolean
  allowComments: boolean
  creator?: {
    id: number
    name: string
    avatar?: string
  }
}

interface Participant {
  id: number
  name: string
  avatar?: string
  relation?: string
  joinTime: string
  status?: string
  isCreator?: boolean
}

interface ActivityPhoto {
  id: number
  thumbnailUrl: string
  originalUrl: string
  description?: string
  uploadTime: string
  uploaderName: string
  uploaderAvatar?: string
}

interface Comment {
  id: number
  content: string
  createTime: string
  likeCount: number
  isLiked: boolean
  user: {
    id: number
    name: string
    avatar?: string
  }
}

interface CurrentUser {
  id: number
  name: string
  avatar?: string
}

interface UploadFile {
  file: File
  name: string
  preview: string
}

// 响应式数据
const loading = ref(true)
const participationLoading = ref(false)
const commentSubmitting = ref(false)
const uploading = ref(false)
const uploadProgress = ref(0)
const showMoreMenu = ref(false)
const showPhotoViewer = ref(false)
const showUploadModal = ref(false)

const activity = ref<Activity | null>(null)
const participants = ref<Participant[]>([])
const activityPhotos = ref<ActivityPhoto[]>([])
const comments = ref<Comment[]>([])
const currentUser = ref<CurrentUser | null>(null)
const currentPhoto = ref<ActivityPhoto | null>(null)
const newComment = ref('')
const uploadFiles = ref<UploadFile[]>([])
const uploadInputRef = ref<HTMLInputElement>()

// 计算属性
const isActivityFull = computed(() => {
  return activity.value?.maxParticipants &&
         activity.value.participantCount >= activity.value.maxParticipants
})

// 方法
const goBack = () => {
  router.back()
}

const editActivity = () => {
  router.push(`/activity/edit/${activity.value?.id}`)
}

const shareActivity = () => {
  // 模拟分享功能
  Notify({
    type: 'success',
    message: '分享链接已复制到剪贴板',
    position: 'top-right'
  })
}

const copyLink = () => {
  // 模拟复制链接
  navigator.clipboard.writeText(window.location.href)
  Notify({
    type: 'success',
    message: '链接已复制到剪贴板',
    position: 'top-right'
  })
  showMoreMenu.value = false
}

const reportActivity = () => {
  // 模拟举报功能
  Notify({
    type: 'info',
    message: '举报已提交，我们会尽快处理',
    position: 'top-right'
  })
  showMoreMenu.value = false
}

const toggleParticipation = async () => {
  if (participationLoading.value || !activity.value) return

  try {
    participationLoading.value = true

    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 1000))

    if (activity.value.isParticipating) {
      activity.value.isParticipating = false
      activity.value.participantCount--
      participants.value = participants.value.filter(p => p.id !== currentUser.value?.id)

      Notify({
        type: 'success',
        message: '已取消参与',
        position: 'top-right'
      })
    } else {
      activity.value.isParticipating = true
      activity.value.participantCount++

      if (currentUser.value) {
        participants.value.push({
          id: currentUser.value.id,
          name: currentUser.value.name,
          avatar: currentUser.value.avatar,
          joinTime: new Date().toISOString(),
          relation: '好友'
        })
      }

      Notify({
        type: 'success',
        message: '参与成功！',
        position: 'top-right'
      })
    }
  } catch (error) {
    console.error('Participation toggle failed:', error)
    Notify({
      type: 'error',
      message: '操作失败，请重试',
      position: 'top-right'
    })
  } finally {
    participationLoading.value = false
  }
}

const submitComment = async () => {
  if (commentSubmitting.value || !newComment.value.trim()) return

  try {
    commentSubmitting.value = true

    // 模拟API调用
    await new Promise(resolve => setTimeout(resolve, 1000))

    const comment: Comment = {
      id: Date.now(),
      content: newComment.value.trim(),
      createTime: new Date().toISOString(),
      likeCount: 0,
      isLiked: false,
      user: {
        id: currentUser.value?.id || 1,
        name: currentUser.value?.name || '我',
        avatar: currentUser.value?.avatar
      }
    }

    comments.value.unshift(comment)
    newComment.value = ''

    Notify({
      type: 'success',
      message: '评论发表成功',
      position: 'top-right'
    })
  } catch (error) {
    console.error('Comment submit failed:', error)
    Notify({
      type: 'error',
      message: '评论发表失败，请重试',
      position: 'top-right'
    })
  } finally {
    commentSubmitting.value = false
  }
}

const toggleCommentLike = (comment: Comment) => {
  comment.isLiked = !comment.isLiked
  comment.likeCount += comment.isLiked ? 1 : -1
}

const replyToComment = (comment: Comment) => {
  newComment.value = `@${comment.user.name} `
  // 滚动到评论输入框
  const commentInput = document.querySelector('.comment-textarea') as HTMLTextAreaElement
  commentInput?.focus()
}

const viewPhoto = (photo: ActivityPhoto) => {
  currentPhoto.value = photo
  showPhotoViewer.value = true
}

const closePhotoViewer = () => {
  showPhotoViewer.value = false
  currentPhoto.value = null
}

const selectFiles = () => {
  uploadInputRef.value?.click()
}

const handleFileSelect = (e: Event) => {
  const input = e.target as HTMLInputElement
  const files = Array.from(input.files || [])
  addUploadFiles(files)
}

const handleDrop = (e: DragEvent) => {
  const files = Array.from(e.dataTransfer?.files || [])
  addUploadFiles(files)
}

const addUploadFiles = (files: File[]) => {
  files.forEach(file => {
    if (file.type.startsWith('image/')) {
      if (file.size > 10 * 1024 * 1024) {
        Notify({
          type: 'warning',
          message: `${file.name} 文件过大，请选择小于10MB的图片`,
          position: 'top-right'
        })
        return
      }

      const reader = new FileReader()
      reader.onload = (e) => {
        uploadFiles.value.push({
          file,
          name: file.name,
          preview: e.target?.result as string
        })
      }
      reader.readAsDataURL(file)
    } else {
      Notify({
        type: 'warning',
        message: `${file.name} 不是有效的图片文件`,
        position: 'top-right'
      })
    }
  })
}

const removeUploadFile = (index: number) => {
  uploadFiles.value.splice(index, 1)
}

const uploadPhotos = async () => {
  if (uploading.value || uploadFiles.value.length === 0) return

  try {
    uploading.value = true
    uploadProgress.value = 0

    // 模拟上传进度
    const progressInterval = setInterval(() => {
      uploadProgress.value += 10
      if (uploadProgress.value >= 90) {
        clearInterval(progressInterval)
      }
    }, 200)

    // 模拟上传API调用
    await new Promise(resolve => setTimeout(resolve, 2000))

    uploadProgress.value = 100
    clearInterval(progressInterval)

    // 添加到活动相册
    uploadFiles.value.forEach((file, index) => {
      activityPhotos.value.push({
        id: Date.now() + index,
        thumbnailUrl: file.preview,
        originalUrl: file.preview,
        description: file.name,
        uploadTime: new Date().toISOString(),
        uploaderName: currentUser.value?.name || '我',
        uploaderAvatar: currentUser.value?.avatar
      })
    })

    uploadFiles.value = []
    showUploadModal.value = false

    Notify({
      type: 'success',
      message: '照片上传成功',
      position: 'top-right'
    })
  } catch (error) {
    console.error('Upload failed:', error)
    Notify({
      type: 'error',
      message: '上传失败，请重试',
      position: 'top-right'
    })
  } finally {
    uploading.value = false
    uploadProgress.value = 0
  }
}

const getStatusText = (status: string): string => {
  const statusMap: Record<string, string> = {
    draft: '草稿',
    published: '已发布',
    ongoing: '进行中',
    completed: '已完成',
    cancelled: '已取消'
  }
  return statusMap[status] || status
}

const getTypeText = (type: string): string => {
  const typeMap: Record<string, string> = {
    family: '家庭聚会',
    dining: '聚餐聚食',
    travel: '旅行出游',
    sports: '运动健身',
    entertainment: '娱乐休闲',
    learning: '学习培训',
    celebration: '庆祝活动',
    outdoor: '户外活动',
    culture: '文化艺术',
    volunteer: '志愿服务',
    other: '其他活动'
  }
  return typeMap[type] || type
}

const getParticipantStatusText = (status: string): string => {
  const statusMap: Record<string, string> = {
    confirmed: '已确认',
    pending: '待确认',
    declined: '已拒绝'
  }
  return statusMap[status] || status
}

const formatDateTime = (dateTime: string): string => {
  const date = new Date(dateTime)
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: 'long',
    day: 'numeric',
    hour: '2-digit',
    minute: '2-digit'
  })
}

const formatRelativeTime = (dateTime: string): string => {
  const date = new Date(dateTime)
  const now = new Date()
  const diffTime = now.getTime() - date.getTime()
  const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24))
  const diffHours = Math.floor(diffTime / (1000 * 60 * 60))
  const diffMinutes = Math.floor(diffTime / (1000 * 60))

  if (diffDays > 0) {
    return `${diffDays}天前`
  } else if (diffHours > 0) {
    return `${diffHours}小时前`
  } else if (diffMinutes > 0) {
    return `${diffMinutes}分钟前`
  } else {
    return '刚刚'
  }
}

const formatCurrency = (amount: number, currency: string): string => {
  const currencyMap: Record<string, string> = {
    CNY: '¥',
    USD: '$',
    EUR: '€'
  }
  return `${currencyMap[currency] || currency} ${amount}`
}

// 页面初始化
onMounted(async () => {
  try {
    // 模拟加载活动数据
    await new Promise(resolve => setTimeout(resolve, 1000))

    const activityId = parseInt(route.params.id as string)

    // 模拟数据
    activity.value = {
      id: activityId,
      title: '周末家庭聚餐',
      description: '准备一顿丰盛的家庭聚餐，大家一起分享美食和欢乐时光。让我们在温馨的家庭氛围中，享受彼此的陪伴，分享生活中的点点滴滴。',
      type: 'dining',
      status: 'published',
      startTime: '2024-01-27T18:00:00',
      endTime: '2024-01-27T20:00:00',
      locationName: '家里',
      locationAddress: '北京市朝阳区某某小区1号楼',
      coverImage: '/images/family-dinner.jpg',
      participantCount: 6,
      maxParticipants: 8,
      budgetPerPerson: 50,
      currency: 'CNY',
      registrationDeadline: '2024-01-27T12:00:00',
      requirements: '请自带好心情，不需要带任何物品',
      notes: '如果临时有事无法参加，请提前告知',
      isParticipating: false,
      canParticipate: true,
      canEdit: true,
      canDelete: true,
      canShare: true,
      canUpload: true,
      allowComments: true,
      creator: {
        id: 1,
        name: '张小明',
        avatar: '/images/avatars/user1.jpg'
      }
    }

    // 模拟参与者数据
    participants.value = [
      {
        id: 1,
        name: '张小明',
        avatar: '/images/avatars/user1.jpg',
        relation: '创建者',
        joinTime: '2024-01-20T10:00:00',
        status: 'confirmed',
        isCreator: true
      },
      {
        id: 2,
        name: '李小红',
        avatar: '/images/avatars/user2.jpg',
        relation: '家庭成员',
        joinTime: '2024-01-20T11:30:00',
        status: 'confirmed'
      },
      {
        id: 3,
        name: '王大华',
        avatar: '/images/avatars/user3.jpg',
        relation: '朋友',
        joinTime: '2024-01-21T09:15:00',
        status: 'pending'
      }
    ]

    // 模拟活动相册
    activityPhotos.value = [
      {
        id: 1,
        thumbnailUrl: '/images/activity/photo1-thumb.jpg',
        originalUrl: '/images/activity/photo1.jpg',
        description: '美味的家常菜',
        uploadTime: '2024-01-25T19:30:00',
        uploaderName: '张小明',
        uploaderAvatar: '/images/avatars/user1.jpg'
      },
      {
        id: 2,
        thumbnailUrl: '/images/activity/photo2-thumb.jpg',
        originalUrl: '/images/activity/photo2.jpg',
        description: '温馨的家庭合照',
        uploadTime: '2024-01-25T20:00:00',
        uploaderName: '李小红',
        uploaderAvatar: '/images/avatars/user2.jpg'
      }
    ]

    // 模拟评论数据
    comments.value = [
      {
        id: 1,
        content: '这个活动很棒！期待和大家一起度过愉快的时光。',
        createTime: '2024-01-22T14:30:00',
        likeCount: 3,
        isLiked: false,
        user: {
          id: 2,
          name: '李小红',
          avatar: '/images/avatars/user2.jpg'
        }
      },
      {
        id: 2,
        content: '我会准时参加的，有什么需要帮忙准备的吗？',
        createTime: '2024-01-22T16:45:00',
        likeCount: 1,
        isLiked: true,
        user: {
          id: 3,
          name: '王大华',
          avatar: '/images/avatars/user3.jpg'
        }
      }
    ]

    // 模拟当前用户
    currentUser.value = {
      id: 4,
      name: '我',
      avatar: '/images/avatars/current-user.jpg'
    }

  } catch (error) {
    console.error('Load activity failed:', error)
    activity.value = null
  } finally {
    loading.value = false
  }

  // 点击外部隐藏更多菜单
  document.addEventListener('click', () => {
    showMoreMenu.value = false
  })
})
</script>

<style lang="scss" scoped>
.activity-detail-view {
  background: #f8fafc;
  min-height: 100vh;

  .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    color: #6b7280;

    .loading-spinner {
      width: 40px;
      height: 40px;
      border: 3px solid #e5e7eb;
      border-top-color: #3b82f6;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin-bottom: 1rem;
    }
  }

  .error-state {
    text-align: center;
    padding: 4rem 2rem;
    margin: 2rem auto;
    max-width: 500px;
    border-radius: 12px;

    svg {
      width: 64px;
      height: 64px;
      color: #ef4444;
      margin-bottom: 1.5rem;
    }

    h3 {
      font-size: 1.5rem;
      font-weight: 600;
      color: #374151;
      margin: 0 0 0.5rem 0;
    }

    p {
      color: #6b7280;
      margin: 0 0 2rem 0;
    }

    .back-btn {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1.5rem;
      background: #3b82f6;
      color: white;
      border: none;
      border-radius: 8px;
      text-decoration: none;
      font-weight: 500;
      cursor: pointer;
      transition: background 0.2s ease;

      &:hover {
        background: #2563eb;
      }

      svg {
        width: 16px;
        height: 16px;
        margin: 0;
      }
    }
  }

  .activity-content {
    .activity-header {
      position: relative;
      height: 400px;
      overflow: hidden;

      .header-background {
        position: absolute;
        inset: 0;

        img {
          width: 100%;
          height: 100%;
          object-fit: cover;
        }

        .placeholder-background {
          width: 100%;
          height: 100%;
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .header-overlay {
          position: absolute;
          inset: 0;
          background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.6));
        }
      }

      .header-content {
        position: relative;
        z-index: 10;
        height: 100%;
        max-width: 1200px;
        margin: 0 auto;
        padding: 2rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        color: white;

        .header-top {
          display: flex;
          justify-content: space-between;
          align-items: center;

          .back-btn {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            background: rgba(255, 255, 255, 0.2);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            backdrop-filter: blur(10px);
            transition: background 0.2s ease;

            &:hover {
              background: rgba(255, 255, 255, 0.3);
            }

            svg {
              width: 16px;
              height: 16px;
            }
          }

          .header-actions {
            display: flex;
            gap: 0.75rem;
            position: relative;

            .action-btn {
              display: flex;
              align-items: center;
              gap: 0.5rem;
              padding: 0.5rem 1rem;
              background: rgba(255, 255, 255, 0.2);
              color: white;
              border: none;
              border-radius: 8px;
              cursor: pointer;
              backdrop-filter: blur(10px);
              font-size: 0.9rem;
              font-weight: 500;
              transition: background 0.2s ease;

              &:hover {
                background: rgba(255, 255, 255, 0.3);
              }

              svg {
                width: 16px;
                height: 16px;
              }
            }

            .more-menu {
              position: absolute;
              top: 100%;
              right: 0;
              background: white;
              border: 1px solid #e5e7eb;
              border-radius: 8px;
              box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
              min-width: 150px;
              overflow: hidden;
              z-index: 20;

              .menu-item {
                display: flex;
                align-items: center;
                gap: 0.75rem;
                width: 100%;
                padding: 0.75rem 1rem;
                border: none;
                background: none;
                text-align: left;
                color: #374151;
                cursor: pointer;
                transition: background 0.2s ease;

                &:hover {
                  background: #f3f4f6;
                }

                svg {
                  width: 16px;
                  height: 16px;
                }
              }
            }
          }
        }

        .header-main {
          .activity-status {
            display: inline-flex;
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 600;
            margin-bottom: 1rem;
            backdrop-filter: blur(10px);

            &.draft {
              background: rgba(107, 114, 128, 0.8);
              color: white;
            }

            &.published {
              background: rgba(59, 130, 246, 0.8);
              color: white;
            }

            &.ongoing {
              background: rgba(34, 197, 94, 0.8);
              color: white;
            }

            &.completed {
              background: rgba(156, 163, 175, 0.8);
              color: white;
            }
          }

          .activity-title {
            font-size: 2.5rem;
            font-weight: 700;
            line-height: 1.2;
            margin: 0 0 1rem 0;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
          }

          .activity-meta {
            display: flex;
            flex-wrap: wrap;
            gap: 1.5rem;

            .meta-item {
              display: flex;
              align-items: center;
              gap: 0.5rem;
              font-size: 0.95rem;
              font-weight: 500;

              svg {
                width: 18px;
                height: 18px;
                opacity: 0.9;
              }
            }
          }
        }
      }
    }

    .participation-section {
      margin: 2rem auto;
      max-width: 1200px;
      padding: 2rem;
      border-radius: 12px;

      .participation-content {
        display: flex;
        justify-content: space-between;
        align-items: center;

        .participation-info {
          .participation-count {
            display: flex;
            align-items: baseline;
            gap: 0.25rem;
            margin-bottom: 0.5rem;

            .count-number {
              font-size: 2rem;
              font-weight: 700;
              color: #1e293b;
            }

            .count-max {
              font-size: 1.25rem;
              font-weight: 600;
              color: #64748b;
            }

            .count-text {
              color: #64748b;
              margin-left: 0.5rem;
            }
          }

          .registration-deadline {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: #f59e0b;
            font-size: 0.9rem;
            font-weight: 500;

            svg {
              width: 16px;
              height: 16px;
            }
          }
        }

        .participate-btn {
          display: flex;
          align-items: center;
          gap: 0.75rem;
          padding: 1rem 2rem;
          border: none;
          border-radius: 12px;
          font-size: 1.1rem;
          font-weight: 600;
          cursor: pointer;
          transition: all 0.2s ease;

          &:not(.participating):not(.full):not(:disabled) {
            background: #3b82f6;
            color: white;

            &:hover {
              background: #2563eb;
              transform: translateY(-1px);
              box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
            }
          }

          &.participating {
            background: #16a34a;
            color: white;

            &:hover {
              background: #15803d;
            }
          }

          &.full {
            background: #f3f4f6;
            color: #6b7280;
            cursor: not-allowed;
          }

          &:disabled {
            opacity: 0.6;
            cursor: not-allowed;
          }

          svg {
            width: 20px;
            height: 20px;
          }

          .loading-spinner {
            animation: spin 1s linear infinite;
          }
        }
      }
    }

    .activity-details {
      max-width: 1200px;
      margin: 0 auto 2rem;
      padding: 0 2rem;
      display: flex;
      flex-direction: column;
      gap: 2rem;

      .detail-section {
        padding: 2rem;
        border-radius: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

        .section-header {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 1.5rem;

          .section-title {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            font-size: 1.25rem;
            font-weight: 600;
            color: #1e293b;
            margin: 0;

            svg {
              width: 20px;
              height: 20px;
              color: #3b82f6;
            }
          }

          .upload-btn {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            background: #3b82f6;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 500;
            transition: background 0.2s ease;

            &:hover {
              background: #2563eb;
            }

            svg {
              width: 14px;
              height: 14px;
            }
          }
        }

        .section-content {
          .activity-description {
            font-size: 1rem;
            line-height: 1.6;
            color: #374151;
            margin: 0 0 2rem 0;
          }

          .no-description {
            color: #9ca3af;
            font-style: italic;
            margin: 0 0 2rem 0;
          }

          .detail-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 1.5rem;

            .detail-item {
              display: flex;
              flex-direction: column;
              gap: 0.5rem;

              &.full-width {
                grid-column: 1 / -1;
              }

              .detail-label {
                display: flex;
                align-items: center;
                gap: 0.5rem;
                font-size: 0.9rem;
                font-weight: 600;
                color: #6b7280;

                svg {
                  width: 16px;
                  height: 16px;
                  color: #9ca3af;
                }
              }

              .detail-value {
                font-size: 1rem;
                color: #1e293b;
                font-weight: 500;

                .detail-sub {
                  font-size: 0.9rem;
                  color: #6b7280;
                  font-weight: 400;
                  margin-top: 0.25rem;
                }
              }
            }
          }

          .participants-list {
            display: flex;
            flex-direction: column;
            gap: 1rem;

            .participant-item {
              display: flex;
              align-items: center;
              gap: 1rem;
              padding: 1rem;
              background: #f8fafc;
              border-radius: 8px;
              transition: background 0.2s ease;

              &:hover {
                background: #f1f5f9;
              }

              .participant-avatar {
                position: relative;
                width: 48px;
                height: 48px;
                border-radius: 50%;
                overflow: hidden;
                flex-shrink: 0;

                img {
                  width: 100%;
                  height: 100%;
                  object-fit: cover;
                }

                .avatar-placeholder {
                  width: 100%;
                  height: 100%;
                  background: #e5e7eb;
                  color: #6b7280;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  font-weight: 600;
                  font-size: 1.25rem;
                }

                .creator-badge {
                  position: absolute;
                  top: -2px;
                  right: -2px;
                  width: 18px;
                  height: 18px;
                  background: #f59e0b;
                  color: white;
                  border-radius: 50%;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  border: 2px solid white;

                  svg {
                    width: 10px;
                    height: 10px;
                  }
                }
              }

              .participant-info {
                flex: 1;

                .participant-name {
                  font-weight: 600;
                  color: #1e293b;
                  margin-bottom: 0.25rem;
                }

                .participant-meta {
                  display: flex;
                  gap: 1rem;
                  font-size: 0.85rem;
                  color: #6b7280;
                }
              }

              .participant-status {
                padding: 0.25rem 0.75rem;
                border-radius: 15px;
                font-size: 0.75rem;
                font-weight: 600;

                &.confirmed {
                  background: #dcfce7;
                  color: #16a34a;
                }

                &.pending {
                  background: #fef3c7;
                  color: #d97706;
                }

                &.declined {
                  background: #fecaca;
                  color: #dc2626;
                }
              }
            }
          }

          .empty-participants {
            text-align: center;
            padding: 2rem;
            color: #9ca3af;

            svg {
              width: 48px;
              height: 48px;
              margin-bottom: 1rem;
            }

            p {
              margin: 0;
            }
          }

          .photos-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 1rem;

            .photo-item {
              position: relative;
              aspect-ratio: 1;
              border-radius: 8px;
              overflow: hidden;
              cursor: pointer;
              transition: transform 0.2s ease;

              &:hover {
                transform: scale(1.02);

                .photo-overlay {
                  opacity: 1;
                }
              }

              img {
                width: 100%;
                height: 100%;
                object-fit: cover;
              }

              .photo-overlay {
                position: absolute;
                inset: 0;
                background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.7));
                display: flex;
                align-items: flex-end;
                padding: 0.75rem;
                opacity: 0;
                transition: opacity 0.2s ease;

                .photo-info {
                  color: white;

                  .photo-uploader {
                    font-size: 0.9rem;
                    font-weight: 600;
                    margin-bottom: 0.25rem;
                  }

                  .photo-time {
                    font-size: 0.8rem;
                    opacity: 0.9;
                  }
                }
              }
            }
          }

          .comment-input {
            display: flex;
            gap: 1rem;
            margin-bottom: 2rem;

            .user-avatar {
              width: 40px;
              height: 40px;
              border-radius: 50%;
              overflow: hidden;
              flex-shrink: 0;

              img {
                width: 100%;
                height: 100%;
                object-fit: cover;
              }

              .avatar-placeholder {
                width: 100%;
                height: 100%;
                background: #e5e7eb;
                color: #6b7280;
                display: flex;
                align-items: center;
                justify-content: center;
                font-weight: 600;
              }
            }

            .input-container {
              flex: 1;

              .comment-textarea {
                width: 100%;
                padding: 0.75rem;
                border: 1px solid #d1d5db;
                border-radius: 8px;
                font-size: 0.9rem;
                line-height: 1.5;
                resize: vertical;
                min-height: 80px;

                &:focus {
                  outline: none;
                  border-color: #3b82f6;
                  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
                }

                &::placeholder {
                  color: #9ca3af;
                }
              }

              .input-actions {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-top: 0.75rem;

                .input-counter {
                  font-size: 0.8rem;
                  color: #9ca3af;
                }

                .submit-btn {
                  display: flex;
                  align-items: center;
                  gap: 0.5rem;
                  padding: 0.5rem 1rem;
                  background: #3b82f6;
                  color: white;
                  border: none;
                  border-radius: 6px;
                  cursor: pointer;
                  font-size: 0.85rem;
                  font-weight: 500;
                  transition: background 0.2s ease;

                  &:hover:not(:disabled) {
                    background: #2563eb;
                  }

                  &:disabled {
                    opacity: 0.6;
                    cursor: not-allowed;
                  }

                  svg {
                    width: 14px;
                    height: 14px;
                  }

                  .loading-spinner {
                    animation: spin 1s linear infinite;
                  }
                }
              }
            }
          }

          .comments-list {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;

            .comment-item {
              display: flex;
              gap: 1rem;

              .comment-avatar {
                width: 40px;
                height: 40px;
                border-radius: 50%;
                overflow: hidden;
                flex-shrink: 0;

                img {
                  width: 100%;
                  height: 100%;
                  object-fit: cover;
                }

                .avatar-placeholder {
                  width: 100%;
                  height: 100%;
                  background: #e5e7eb;
                  color: #6b7280;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  font-weight: 600;
                }
              }

              .comment-content {
                flex: 1;

                .comment-header {
                  display: flex;
                  align-items: center;
                  gap: 1rem;
                  margin-bottom: 0.5rem;

                  .comment-author {
                    font-weight: 600;
                    color: #1e293b;
                  }

                  .comment-time {
                    font-size: 0.8rem;
                    color: #9ca3af;
                  }
                }

                .comment-text {
                  color: #374151;
                  line-height: 1.5;
                  margin-bottom: 0.75rem;
                }

                .comment-actions {
                  display: flex;
                  gap: 1rem;

                  .comment-action {
                    display: flex;
                    align-items: center;
                    gap: 0.25rem;
                    padding: 0.25rem 0.5rem;
                    border: none;
                    background: none;
                    color: #9ca3af;
                    cursor: pointer;
                    font-size: 0.8rem;
                    border-radius: 4px;
                    transition: all 0.2s ease;

                    &:hover {
                      color: #6b7280;
                      background: #f3f4f6;
                    }

                    &.active {
                      color: #ef4444;
                    }

                    svg {
                      width: 14px;
                      height: 14px;
                    }
                  }
                }
              }
            }
          }

          .empty-comments {
            text-align: center;
            padding: 2rem;
            color: #9ca3af;

            svg {
              width: 48px;
              height: 48px;
              margin-bottom: 1rem;
            }

            p {
              margin: 0;
            }
          }
        }
      }
    }
  }

  .photo-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;

    .photo-viewer-content {
      position: relative;
      max-width: 90vw;
      max-height: 90vh;

      .viewer-close {
        position: absolute;
        top: -50px;
        right: 0;
        background: none;
        border: none;
        color: white;
        cursor: pointer;
        padding: 0.5rem;

        svg {
          width: 24px;
          height: 24px;
        }
      }

      img {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 8px;
      }

      .photo-info-panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
        color: white;
        padding: 2rem 1rem 1rem;

        .info-header {
          .uploader-info {
            display: flex;
            align-items: center;
            gap: 0.75rem;

            .uploader-avatar {
              width: 32px;
              height: 32px;
              border-radius: 50%;
              overflow: hidden;

              img {
                width: 100%;
                height: 100%;
                object-fit: cover;
              }

              .avatar-placeholder {
                width: 100%;
                height: 100%;
                background: rgba(255, 255, 255, 0.2);
                color: white;
                display: flex;
                align-items: center;
                justify-content: center;
                font-weight: 600;
                font-size: 0.9rem;
              }
            }

            .uploader-name {
              font-weight: 600;
            }

            .upload-time {
              font-size: 0.85rem;
              opacity: 0.9;
            }
          }
        }

        .photo-description {
          margin-top: 0.75rem;
          font-size: 0.9rem;
          opacity: 0.9;
        }
      }
    }
  }

  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;

    .modal-dialog {
      background: white;
      border-radius: 12px;
      width: 90vw;
      max-width: 600px;
      max-height: 90vh;
      overflow: hidden;
      display: flex;
      flex-direction: column;

      .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1.5rem 1.5rem 1rem;
        border-bottom: 1px solid #f1f5f9;

        h3 {
          margin: 0;
          color: #1e293b;
        }

        .modal-close {
          background: none;
          border: none;
          color: #6b7280;
          cursor: pointer;
          padding: 0.25rem;

          svg {
            width: 20px;
            height: 20px;
          }
        }
      }

      .modal-body {
        padding: 1.5rem;
        flex: 1;
        overflow-y: auto;

        .upload-area {
          border: 2px dashed #d1d5db;
          border-radius: 8px;
          padding: 2rem;
          text-align: center;
          cursor: pointer;
          transition: border-color 0.2s ease;
          margin-bottom: 1rem;

          &:hover {
            border-color: #3b82f6;
          }

          .upload-content {
            svg {
              width: 48px;
              height: 48px;
              color: #9ca3af;
              margin-bottom: 1rem;
            }

            h4 {
              font-size: 1.1rem;
              font-weight: 600;
              color: #374151;
              margin: 0 0 0.5rem 0;
            }

            p {
              color: #6b7280;
              margin: 0;
            }
          }
        }

        .file-input {
          display: none;
        }

        .upload-preview {
          h4 {
            font-size: 1rem;
            font-weight: 600;
            color: #374151;
            margin: 0 0 1rem 0;
          }

          .preview-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
            gap: 0.75rem;

            .preview-item {
              position: relative;
              aspect-ratio: 1;
              border-radius: 6px;
              overflow: hidden;

              img {
                width: 100%;
                height: 100%;
                object-fit: cover;
              }

              .remove-file {
                position: absolute;
                top: 4px;
                right: 4px;
                width: 20px;
                height: 20px;
                background: rgba(239, 68, 68, 0.9);
                color: white;
                border: none;
                border-radius: 50%;
                cursor: pointer;
                display: flex;
                align-items: center;
                justify-content: center;

                svg {
                  width: 12px;
                  height: 12px;
                }
              }
            }
          }
        }
      }

      .modal-footer {
        display: flex;
        justify-content: flex-end;
        gap: 0.75rem;
        padding: 1rem 1.5rem 1.5rem;
        border-top: 1px solid #f1f5f9;

        .modal-btn {
          padding: 0.5rem 1rem;
          border-radius: 6px;
          border: none;
          cursor: pointer;
          font-size: 0.9rem;
          font-weight: 500;
          display: flex;
          align-items: center;
          gap: 0.5rem;
          transition: background 0.2s ease;

          &.secondary {
            background: #f3f4f6;
            color: #374151;

            &:hover {
              background: #e5e7eb;
            }
          }

          &.primary {
            background: #3b82f6;
            color: white;

            &:hover:not(:disabled) {
              background: #2563eb;
            }

            &:disabled {
              opacity: 0.6;
              cursor: not-allowed;
            }
          }

          svg {
            width: 16px;
            height: 16px;
          }

          .loading-spinner {
            animation: spin 1s linear infinite;
          }
        }
      }
    }
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

// 响应式设计
@media (max-width: 1024px) {
  .activity-detail-view {
    .activity-content {
      .activity-header {
        height: 300px;

        .header-content {
          padding: 1.5rem;

          .header-main .activity-title {
            font-size: 2rem;
          }
        }
      }

      .participation-section {
        margin: 1.5rem;
        padding: 1.5rem;
      }

      .activity-details {
        padding: 0 1.5rem;

        .detail-section {
          padding: 1.5rem;

          .section-content .detail-grid {
            grid-template-columns: 1fr;
          }
        }
      }
    }
  }
}

@media (max-width: 768px) {
  .activity-detail-view {
    .activity-content {
      .activity-header {
        height: 250px;

        .header-content {
          padding: 1rem;

          .header-top .header-actions {
            gap: 0.5rem;

            .action-btn {
              padding: 0.4rem 0.8rem;
              font-size: 0.8rem;

              svg {
                width: 14px;
                height: 14px;
              }
            }
          }

          .header-main {
            .activity-title {
              font-size: 1.5rem;
            }

            .activity-meta {
              gap: 1rem;

              .meta-item {
                font-size: 0.85rem;

                svg {
                  width: 16px;
                  height: 16px;
                }
              }
            }
          }
        }
      }

      .participation-section {
        margin: 1rem;
        padding: 1rem;

        .participation-content {
          flex-direction: column;
          gap: 1rem;
          text-align: center;

          .participation-info .participation-count {
            justify-content: center;
          }
        }
      }

      .activity-details {
        padding: 0 1rem;

        .detail-section {
          padding: 1rem;

          .section-content {
            .photos-grid {
              grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
              gap: 0.75rem;
            }

            .comment-input {
              gap: 0.75rem;

              .user-avatar {
                width: 36px;
                height: 36px;
              }

              .input-container .input-actions {
                flex-direction: column;
                align-items: stretch;
                gap: 0.75rem;

                .submit-btn {
                  width: 100%;
                  justify-content: center;
                }
              }
            }

            .comments-list .comment-item {
              gap: 0.75rem;

              .comment-avatar {
                width: 36px;
                height: 36px;
              }
            }
          }
        }
      }
    }

    .photo-viewer .photo-viewer-content .photo-info-panel {
      padding: 1.5rem 1rem 1rem;
    }

    .modal-overlay .modal-dialog {
      width: 95vw;

      .modal-body .upload-area {
        padding: 1.5rem;

        .upload-content {
          svg {
            width: 40px;
            height: 40px;
          }

          h4 {
            font-size: 1rem;
          }

          p {
            font-size: 0.85rem;
          }
        }
      }
    }
  }
}
</style>
